<template>
    <div class="SerBasicInformation">
        <el-row class="serBasicLine-box" :gutter="20">
            <el-col :span="6" class="serBasicName">
                <p>IP 地址：123456789</p>
                <!-- {{ selectedMonID.selectedIP? selectedMonID.selectedIP : " " }} -->
            </el-col>
            <el-col :span="6" class="serBasicName">
                <p>主机名：123456789</p>
                <!-- {{ osData.HOSTNAME? osData.HOSTNAME : " " }} -->
            </el-col>
        </el-row>
        <el-row class="serBasicLine-box" :gutter="20">
            <el-col :span="6" class="serBasicName">
                <p>平台：123456789</p>
                <!-- {{ osData.RELEASE? osData.RELEASE : " " }} -->
            </el-col>
            <el-col :span="6" class="serBasicName">
                <p>CPU 核数：123456789</p>
                <!-- {{ osData.CPU_COUNT? osData.CPU_COUNT : " " }} -->
            </el-col>
        </el-row>
        <el-row class="serBasicLine-box" :gutter="20">
            <el-col :span="6" class="serBasicName">
                <p>物理内存：123456789</p>
                <!-- {{ osData.MEMORY_GB? osData.MEMORY_GB+" GB" : " " }} -->
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { fetchData } from '@/api/index.js';
import bus from 'common/bus.js';

export default {
    data() {
        return {
            postData: {
                opera: 'ospanlinfo',
                curPage: 1,
                pageSize: 20,
                sort: {
                    sortColumn: '',
                    sortOrders: ''
                },
                filtersType: 'fuzzyquery',
                filters: {
                    "monid":""
                },
            },
            // ip: '',
            // hostName: '',
            // os: '',
            // cpuNumber: '',
            // physicalMemory: '',
            osData: {},
            selectedMonID: {},
            timerName: 'SerBasicInformation',
            timerEventName: 'timerSerBasicInformation',
            timerInterval: 1000 * 60,
            selectedMonID: {},
            osData: {}
        }
    },
    created() {
        bus.$on('selectedMonIDServer', msg => {
            this.resetData();
            
            this.selectedMonID = msg;
            this.postData.filters.monid = this.selectedMonID.selectedOSMonID;
            this.getData();
        }); 
        
        bus.$emit('timerNewTodo', {
            name: this.timerName,
            eventName: this.timerEventName,
            interval: this.timerInterval,
            intervalNow: 0
        });

        bus.$on(this.timerEventName, msg => {
            if (msg.isGetData) {
                this.resetData();

                this.getData();
            }
        });
        
    },
    mounted() {

    },
    computed: {
        postDataFn() {
            return {
                postData : JSON.stringify(this.postData)
            }
        }
    },
    methods: {
        getData(){
            fetchData(
                this.postDataFn
            ).then((res) => {
                if (res.data.length > 0) {
                    this.osData = res.data[0];
                }
            });
        },
        resetData() {
            this.osData = {};
        }
    },
    beforeDestroy() {
        bus.$emit('timerNewTodo', {
            name: this.timerName
        });
    },
    watch:{
        
    }
}
</script>

<style scoped>
.SerBasicInformation{
    padding: 0px 5px;
    height: calc(100% - 22px - 8px);
    text-align: center;
    color: rgb(61, 12, 240);
}
.SerBasicInformation > .serBasicLine-box {
    height: calc((100% - 30%) / 4);
    overflow: hidden;
    margin: 10px 0 10px 20px;
}
.SerBasicInformation .pintai-box{
    height: 30%;
    overflow: hidden;
}
.SerBasicInformation > div > div {
    height: 100%;
    display: flex;
}


.serBasicName{
    margin-left: 10px;
}
.lableNumber{
    width: auto;
    overflow: hidden;
    text-align: left;
}
</style>    